<?php

namespace app\admin\model;

use think\model\concern\SoftDelete;

trait TraitModel
{
    use SoftDelete;
    protected $deleteTime = 'delete_time';

    public function getLst($data = [null])
    {
        $args = [
            'where' => null,
            'order' => null,
            'field' => null,
            'ispage' => false,
            'limit' => 0,
            'pageQuery' => null,
        ];
        $argsMerge = array_merge($args, $data);
        if ($data) {
            if ($argsMerge['ispage']) {
                $res = $this->where($argsMerge['where'])->order($argsMerge['order'])->field($argsMerge['field'])->paginate($argsMerge['limit'], false, ['query' => $argsMerge['pageQuery']]);
            } else {
                $res = $this->where($argsMerge['where'])->order($argsMerge['order'])->field($argsMerge['field'])->limit($argsMerge['limit'])->select();
            }
        } else {
            $res = $this->select();
        }

        return $res;
    }
}
